package com.siyuanren.gcocp.input;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by   anxing
 * Project_name wordGame
 * Path         com.woodstar.word
 * Date         2018/6/19
 * Time         16:21
 * Description
 */
public class Word2Parse {

    /**
     * 当前正在处理的词缀
     */
    String currPart;
    String currrPartTrans;


    public boolean parsePartFirt(String line) throws Exception {
        boolean parse = false;
        String partFirst = "([\\uFEFF]*[a-zA-Z]+)[--]+[①②]*$";  // un-
        if (Pattern.matches(partFirst, line)) {
            currPart = line;
            currrPartTrans=null;
            parse = true;
        }

        String partFirstEx = "([a-zA-Z]+)-[\\u2E80-\\u9FFFa-zA-Z=(--)（）.，、① ②]*";  //with-向后、相反
        if (Pattern.matches(partFirstEx, line)) {
            String[] split = line.split("-");
            int index = line.indexOf("-");
            currPart = line.substring(0, index+1);
            currrPartTrans = line.substring(index+1);
            parse = true;
        }
        return parse;
    }
    public boolean parsePartTanslate(String line) throws Exception {
        boolean parse = false;
        String partFirstEx = "[0-9１]+[、、、].*";
        if (Pattern.matches(partFirstEx, line)) {
            currrPartTrans = line;
            parse = true;
        }
        return parse;
    }

    public boolean parseWord(String line) throws Exception {
        boolean parse = false;
        String express = "([a-zA-Z]+)[-—]*([a-zA-Z]+)[ 　]+[\\u2E80-\\u9FFFa-zA-Z()（）.，、… =-→0-9；-]*";
        if (Pattern.matches(express, line)) {
            parse = true;
        }
        return parse;
    }



    public static void main(String[] args) {
//        Pattern pattern = Pattern.compile("([a-zA-Z]+)[--]+$");
//        Matcher matcher = pattern.matcher("a-");
//        Pattern pattern = Pattern.compile("([a-zA-Z]+)-[\\u2E80-\\u9FFFa-zA-Z(--)（）.，、]*");
//        Matcher matcher = pattern.matcher("tetra-四（在元音前作tetr-）");
//        Pattern pattern = Pattern.compile("\\d+、.*");
//        Matcher matcher = pattern.matcher("1、无、不、非");
//        Pattern pattern = Pattern.compile("([a-zA-Z]+)-[\\u2E80-\\u9FFF]*");
//        Matcher matcher = pattern.matcher("with-向后、相反");
        Pattern pattern = Pattern.compile("([a-zA-Z]+)[-—]*([a-zA-Z]+)[ 　]+[\\u2E80-\\u9FFFa-zA-Z()（）.，、… =-→0-9；-]*");
        Matcher matcher = pattern.matcher("penumbra       半阴影（pen-几乎，umbra影；几乎是一个阴影，不完全是一个阴影→半阴影）");
        if (matcher.find()) {
            System.out.println("find:" + matcher.group());
            while(matcher.find()){
                System.out.println("find:" + matcher.group());
            }
        } else {
            System.out.println("no find");
        }

    }
}
